Skip to main content

All Questions

6votes
2answers
280views

Update object inside array inside another JSON object

I have a huge JSON object with an array of objects inside it. I have to add key:value pair to a specific object in the array. For example, let the input object is: { "a": { "b&...
Vlado B.'s user avatar
1vote
1answer
59views

json formating with jq for json nested objects

how do I get jq to take json like this: { "responseHeader":{ "status":0, "QTime":1 }, "cluster":{ "collections":{ "...
Claudio Favaro's user avatar
3votes
2answers
1kviews

jq create object with property name from variable

$ n="foo"; echo "{}" | jq --arg n "$n" '. += { "$n": $n }' { "$n": "foo" } My reading of https://jqlang.github.io/jq/manual/#types-and-...
Richard Barraclough's user avatar
-2votes
3answers
113views

Awk to pick up json values

I am trying to get the job status from the below json file.. but while using awk it is returning { "id": 10870, "type": "job", "url": "/api/v2/...
user984993's user avatar
3votes
2answers
615views

Emulate gron using jq

I recently discovered jq and gron. For my use case, gron is sufficient, but I am a little worried by lack of development. There are some bugs that have not been addressed in an year, while I see that ...
Francesco Potortì's user avatar
-2votes
1answer
362views

How to replace a parameter's value in json file with a value taken from a different text file

I have a a large number of JSON files on a Linux machine, where I need to change the value of a parameter with value taken from a different text file. E.g.: If the JSON file has values like: { "...
vishal's user avatar
-1votes
5answers
128views

How to check the contents of an entire file against the pattern \s*{\s*}\s*?

How to check the contents of an entire file for compliance with the pattern \s*{\s*}\s* using busybox? You need to check the entire file from beginning to end, and not individual lines, as grep does. ...
Maxim's user avatar
1vote
3answers
370views

Convert table to json

I have a large table of data that I would like to convert to json and am not sure if a tool like jq, mlr, or similar would be able to perform such a task without having to resort to my poor awk skills....
jesse_b's user avatar
  • 40.4k
7votes
4answers
2kviews

How to gather values into array by keys?

Given input in entries format, possibly with duplicated keys, e.g. [ {"key": "a", "value": 0}, {"key": "a", "value": 1}, {"key&...
友人A's user avatar
0votes
3answers
83views

How to print the content between the third and the forth double quotation marks

I have some logs from a web service on a Linux machine. The logs look like this: {"log":"[2023-03-09T06:39:10.669Z] \"GET /server/prod?blank=true HTTP/1.1\" 200 - 0 874 1 1 \&...
Yves's user avatar
  • 3,401
1vote
1answer
10kviews

jq: error (at input.json:45): Cannot index array with string "value"

I try to convert my .json files to .csv with jq. I'm getting cannot index array with string value on all my values. .json { "organic_data": [ { "description": "...
pwrsheller's user avatar
2votes
0answers
248views

How to combine two JSON objects using jq [closed]

I have two files: kube-apiserver.json { "apiVersion": "v1", "kind": "Pod", "metadata": { [...] }, "spec": { ...
landocalrissian's user avatar
0votes
1answer
1kviews

AWS CLI output append to json file

I have a sample.json with the content below : {key:value} I want the AWS secrets CLI command output (secretstring json object) { user:name, pass:word } to be appended to my JSON file above so that ...
user2573747's user avatar
2votes
2answers
620views

Text file to JSON

I have a text file of IP:PORT, like for example 1.1.1.1:1919 2.2.2.2:111 1.1.1.1:987 I need to use them in a script which has a JSON format: async def main(loop): servers = [{ "...
ph3ro's user avatar
5votes
1answer
13kviews

How to check a value and change other key in JSON with jq?

[ { "name": "user1", "status": "off" }, { "name": "user2", "status": "off" ...
decipher's user avatar

153050per page
close